/*     */ package com.lmpop.trade.shopcart;
/*     */ 
/*     */ import com.lmpop.trade.ti_discountpolicy.Ti_discountpolicyInfo;
/*     */ import com.lmpop.trade.ti_gift.Ti_giftInfo;
/*     */ import java.io.PrintStream;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Hashtable;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Map.Entry;
/*     */ import java.util.Set;
/*     */ 
/*     */ public class CartServices
/*     */ {
/*  23 */   public Hashtable<String, Hashtable<String, Goods>> cartMap = new Hashtable();
/*     */ 
/* 310 */   private String gift_ids = "";
/*     */ 
/* 312 */   private int offer_type = 0;
/*     */ 
/*     */   public Hashtable<String, Hashtable<String, Goods>> getCartMap()
/*     */   {
/*  26 */     return this.cartMap;
/*     */   }
/*     */ 
/*     */   public void setCartMap(Hashtable<String, Hashtable<String, Goods>> cartMap) {
/*  30 */     this.cartMap = cartMap;
/*     */   }
/*     */ 
/*     */   public void addItem(String cust_id, Goods goodsItem)
/*     */   {
/*  35 */     if (cust_id.equals("")) {
/*  36 */       return;
/*     */     }
/*     */ 
/*  41 */     if (this.cartMap.containsKey(cust_id))
/*     */     {
/*  43 */       boolean checkResult = false;
/*  44 */       List all_exist_goodsItemsList = new ArrayList();
/*  45 */       String goods_random_id_str = "";
/*  46 */       Hashtable goodsItems = (Hashtable)this.cartMap.get(cust_id);
/*  47 */       String[] item_goods_random_id = goodsItem.getGoods_id().split("\\/");
/*  48 */       Set goodsItemsKeySet = goodsItems.keySet();
/*  49 */       Iterator goodsItemsKeyIterator = goodsItemsKeySet.iterator();
/*     */ 
/*  51 */       while (goodsItemsKeyIterator.hasNext()) {
/*  52 */         goods_random_id_str = (String)goodsItemsKeyIterator.next();
/*  53 */         String[] goods_random_id = goods_random_id_str.split("\\/");
/*  54 */         if (goods_random_id[0].equals(item_goods_random_id[0])) {
/*  55 */           checkResult = true;
/*  56 */           all_exist_goodsItemsList.add(goods_random_id_str);
/*     */         }
/*     */       }
/*     */ 
/*  60 */       if (checkResult) {
/*  61 */         int list_Size = all_exist_goodsItemsList.size();
/*  62 */         Goods goodsInstance = null;
/*  63 */         String exist_goodsItem_id = "";
/*  64 */         boolean isHasSameProps = false;
/*  65 */         for (int i = 0; i < list_Size; i++) {
/*  66 */           exist_goodsItem_id = (String)all_exist_goodsItemsList.get(i);
/*  67 */           goodsInstance = (Goods)goodsItems.get(exist_goodsItem_id);
/*  68 */           if ((goodsInstance.getGoods_props().trim().equals(goodsItem.getGoods_props().trim())) && (goodsInstance.getType().trim().equals(goodsItem.getType().trim()))) {
/*  69 */             goodsInstance.setBuy_num(goodsItem.getBuy_num() + goodsInstance.getBuy_num());
/*     */ 
/*  71 */             if ((goodsInstance.getDiscount_id() != null) && (!"".equals(goodsInstance.getDiscount_id()))) {
/*  72 */               updateDiscount(goodsInstance);
/*     */             }
/*  74 */             isHasSameProps = true;
/*  75 */             break;
/*     */           }
/*     */         }
/*  78 */         if (!isHasSameProps) {
/*  79 */           System.out.println("------------Debug------------->002<");
/*  80 */           goodsItems.put(goodsItem.getGoods_id(), goodsItem);
/*  81 */           this.cartMap.put(cust_id, goodsItems);
/*  82 */           System.out.println("------------Debug------------->goods has diff props<");
/*     */         }
/*     */       } else {
/*  85 */         goodsItems.put(goodsItem.getGoods_id(), goodsItem);
/*  86 */         this.cartMap.put(cust_id, goodsItems);
/*     */       }
/*     */     }
/*     */     else {
/*  90 */       Hashtable goodsMapItem = new Hashtable();
/*  91 */       goodsMapItem.put(goodsItem.getGoods_id(), goodsItem);
/*  92 */       this.cartMap.put(cust_id, goodsMapItem);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateItemCount(String cust_id, String goods_id, int count, float shop_price)
/*     */   {
/*  98 */     if (cust_id.equals("")) {
/*  99 */       return;
/*     */     }
/* 101 */     if (this.cartMap.containsKey(cust_id)) {
/* 102 */       Hashtable goodsItems = (Hashtable)this.cartMap.get(cust_id);
/* 103 */       if ((goodsItems.containsKey(goods_id)) && (goods_id != null)) {
/* 104 */         Goods goodsInstance = (Goods)goodsItems.get(goods_id);
/* 105 */         goodsInstance.setBuy_num(count);
/*     */ 
/* 107 */         goodsInstance.setShop_price(shop_price);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateDiscountInfo(String cust_id, String goods_id)
/*     */   {
/* 115 */     if (cust_id.equals("")) {
/* 116 */       return;
/*     */     }
/* 118 */     if (this.cartMap.containsKey(cust_id)) {
/* 119 */       Hashtable goodsItems = (Hashtable)this.cartMap.get(cust_id);
/* 120 */       if ((goodsItems.containsKey(goods_id)) && (goods_id != null)) {
/* 121 */         Goods goodsInstance = (Goods)goodsItems.get(goods_id);
/*     */ 
/* 123 */         if ((goodsInstance.getDiscount_id() != null) && (!"".equals(goodsInstance.getDiscount_id())))
/* 124 */           updateDiscount(goodsInstance);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateItemProps(String cust_id, String goods_id, String goods_props)
/*     */   {
/* 134 */     if (cust_id.equals("")) {
/* 135 */       return;
/*     */     }
/*     */ 
/* 138 */     if (this.cartMap.containsKey(cust_id)) {
/* 139 */       System.out.println("goods_id===============" + goods_id);
/* 140 */       Hashtable goodsItems = (Hashtable)this.cartMap.get(cust_id);
/* 141 */       System.out.println("goodsItems===============" + goodsItems);
/* 142 */       if ((goodsItems.containsKey(goods_id)) && (goods_id != null)) {
/* 143 */         System.out.println("updateItemProps===============");
/* 144 */         Goods goodsInstance = (Goods)goodsItems.get(goods_id);
/* 145 */         goodsInstance.setGoods_props(goods_props);
/* 146 */         System.out.println("goodsInstance.getGoods_props()======" + goodsInstance.getGoods_props());
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public void removeGoodsItem(String cust_id, String goods_id)
/*     */   {
/* 155 */     if (cust_id.equals("")) {
/* 156 */       return;
/*     */     }
/* 158 */     System.out.println("----------->" + cust_id + "==========" + this.cartMap);
/* 159 */     if (this.cartMap.containsKey(cust_id)) {
/* 160 */       Hashtable goodsItems = (Hashtable)this.cartMap.get(cust_id);
/* 161 */       System.out.println("----------->" + cust_id);
/* 162 */       if ((goodsItems.containsKey(goods_id)) && (goods_id != null)) {
/* 163 */         goodsItems.remove(goods_id);
/* 164 */         System.out.println("----------->" + goods_id);
/*     */       }
/* 166 */       if (goodsItems.isEmpty())
/* 167 */         this.cartMap.remove(cust_id);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void removeCustGoods(String cust_id)
/*     */   {
/* 175 */     if (cust_id.equals("")) {
/* 176 */       return;
/*     */     }
/* 178 */     if (this.cartMap.containsKey(cust_id))
/* 179 */       this.cartMap.remove(cust_id);
/*     */   }
/*     */ 
/*     */   public void clear()
/*     */   {
/* 186 */     this.cartMap.clear();
/*     */   }
/*     */ 
/*     */   public float getAllItemsPrice()
/*     */   {
/* 192 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 193 */       return 0.0F;
/*     */     }
/* 195 */     float totalPrice = 0.0F;
/* 196 */     Set cartSet = this.cartMap.entrySet();
/* 197 */     Iterator cartIterator = cartSet.iterator();
/* 198 */     while (cartIterator.hasNext()) {
/* 199 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 200 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 201 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 202 */         Set goodsSet = goodsItems.entrySet();
/* 203 */         Iterator iterator = goodsSet.iterator();
/* 204 */         while (iterator.hasNext()) {
/* 205 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 206 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 207 */           totalPrice += goodsInstance.getTotalShopPrice();
/*     */         }
/*     */       }
/*     */     }
/* 211 */     return totalPrice;
/*     */   }
/*     */ 
/*     */   public float getAllItemsVipPrice()
/*     */   {
/* 216 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 217 */       return 0.0F;
/*     */     }
/* 219 */     float totalVipPrice = 0.0F;
/*     */ 
/* 221 */     Set cartSet = this.cartMap.entrySet();
/*     */ 
/* 223 */     Iterator cartIterator = cartSet.iterator();
/*     */ 
/* 225 */     while (cartIterator.hasNext()) {
/* 226 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 227 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 228 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 229 */         Set goodsSet = goodsItems.entrySet();
/* 230 */         Iterator iterator = goodsSet.iterator();
/* 231 */         while (iterator.hasNext()) {
/* 232 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 233 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 234 */           totalVipPrice += goodsInstance.getTotalVipPrice();
/*     */         }
/*     */       }
/*     */     }
/* 238 */     return totalVipPrice;
/*     */   }
/*     */ 
/*     */   public float getAllItemsOfferPrice(int level)
/*     */   {
/* 243 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 244 */       return 0.0F;
/*     */     }
/* 246 */     float totalOfferPrice = 0.0F;
/* 247 */     float totalOrderOfferPrice = 0.0F;
/* 248 */     int buy_num = 0;
/* 249 */     float price = 0.0F;
/* 250 */     Set cartSet = this.cartMap.entrySet();
/*     */ 
/* 252 */     Iterator cartIterator = cartSet.iterator();
/* 253 */     Ti_discountpolicyInfo ti_discountinfo = new Ti_discountpolicyInfo();
/*     */ 
/* 255 */     while (cartIterator.hasNext()) {
/* 256 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 257 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 258 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 259 */         Set goodsSet = goodsItems.entrySet();
/* 260 */         Iterator iterator = goodsSet.iterator();
/* 261 */         while (iterator.hasNext()) {
/* 262 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 263 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 264 */           if (goodsInstance.getOffer_price() > 0.0F) {
/* 265 */             totalOfferPrice += goodsInstance.getTotalOfferPrice();
/*     */           } else {
/* 267 */             buy_num += goodsInstance.getBuy_num();
/* 268 */             price += goodsInstance.getShop_price();
/*     */ 
/* 270 */             totalOrderOfferPrice += goodsInstance.getTotalShopPrice();
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 275 */     if (totalOrderOfferPrice > 0.0F) {
/* 276 */       List list = ti_discountinfo.getDiscountpolicy(level, String.valueOf(price), String.valueOf(buy_num));
/* 277 */       if ((list != null) && (list.size() > 0)) {
/* 278 */         Map map = null;
/* 279 */         int i = 0;
/*     */ 
/* 282 */         map = (Hashtable)list.get(i);
/* 283 */         int type = Integer.parseInt(map.get("offer_type").toString());
/* 284 */         setOffer_type(type);
/* 285 */         if ((type != 2) && (type != 3)) {
/* 286 */           totalOfferPrice += totalOrderOfferPrice;
/* 287 */           setGift_ids(map.get("gift_ids").toString());
/*     */         }
/* 290 */         else if (buy_num >= Integer.parseInt(map.get("number").toString())) {
/* 291 */           totalOrderOfferPrice = totalOrderOfferPrice * Integer.parseInt(map.get("discount").toString()) / 100.0F;
/* 292 */         } else if (price >= Integer.parseInt(map.get("spending").toString())) {
/* 293 */           totalOrderOfferPrice = totalOrderOfferPrice * Integer.parseInt(map.get("discount").toString()) / 100.0F;
/* 294 */         } else if (type == 4) {
/* 295 */           totalOfferPrice += totalOrderOfferPrice - Integer.parseInt(map.get("ship_offer").toString());
/*     */         } else {
/* 297 */           totalOfferPrice += totalOrderOfferPrice;
/* 298 */           setOffer_type(0);
/*     */         }
/*     */       }
/*     */       else
/*     */       {
/* 303 */         totalOfferPrice += totalOrderOfferPrice;
/*     */       }
/*     */     }
/*     */ 
/* 307 */     return totalOfferPrice;
/*     */   }
/*     */ 
/*     */   public void setOffer_type(int type)
/*     */   {
/* 314 */     this.offer_type = type;
/*     */   }
/*     */ 
/*     */   public int getOffer_type()
/*     */   {
/* 319 */     return this.offer_type;
/*     */   }
/*     */ 
/*     */   public String getAllItemsGifts()
/*     */   {
/* 324 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 325 */       return "";
/*     */     }
/* 327 */     Map giftMap = new Hashtable();
/*     */ 
/* 329 */     Set cartSet = this.cartMap.entrySet();
/*     */ 
/* 331 */     Iterator cartIterator = cartSet.iterator();
/* 332 */     Ti_giftInfo ti_giftInfo = new Ti_giftInfo();
/* 333 */     List gifts = null;
/* 334 */     Map temp = null;
/* 335 */     int tempnum = 0;
/* 336 */     while (cartIterator.hasNext()) {
/* 337 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 338 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 339 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 340 */         Set goodsSet = goodsItems.entrySet();
/* 341 */         Iterator iterator = goodsSet.iterator();
/* 342 */         while (iterator.hasNext()) {
/* 343 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 344 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 345 */           if ((goodsInstance.getGift_id() != null) && (!"".equals(goodsInstance.getGift_id()))) {
/* 346 */             gifts = ti_giftInfo.getListByPk(goodsInstance.getGift_id());
/* 347 */             if ((gifts != null) && (gifts.size() > 0)) {
/* 348 */               temp = (Hashtable)gifts.get(0);
/* 349 */               if (giftMap.containsKey(temp.get("gift_name"))) {
/* 350 */                 tempnum = Integer.parseInt(giftMap.get(temp.get("gift_name")).toString());
/* 351 */                 giftMap.put(temp.get("gift_name"), Integer.valueOf(tempnum + goodsInstance.getSendnumber()));
/*     */               }
/*     */               else {
/* 354 */                 giftMap.put(temp.get("gift_name"), Integer.valueOf(goodsInstance.getSendnumber()));
/*     */               }
/*     */             }
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 360 */     if (giftMap.size() > 0) {
/* 361 */       StringBuffer buf = new StringBuffer();
/* 362 */       for (Iterator i$ = giftMap.keySet().iterator(); i$.hasNext(); ) { Object key = i$.next();
/* 363 */         buf.append(key + ":" + giftMap.get(key).toString() + "个;");
/*     */       }
/* 365 */       return buf.toString();
/*     */     }
/* 367 */     return "";
/*     */   }
/*     */ 
/*     */   public String getAllItemsDiscountids()
/*     */   {
/* 372 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 373 */       return "";
/*     */     }
/* 375 */     Map disMap = new Hashtable();
/*     */ 
/* 377 */     Set cartSet = this.cartMap.entrySet();
/*     */ 
/* 379 */     Iterator cartIterator = cartSet.iterator();
/* 380 */     Ti_discountpolicyInfo disinfo = new Ti_discountpolicyInfo();
/* 381 */     List discountids = null;
/* 382 */     Map temp = null;
/* 383 */     int tempnum = 0;
/* 384 */     String tempid = "";
/* 385 */     int num = 0;
/* 386 */     while (cartIterator.hasNext()) {
/* 387 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 388 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 389 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 390 */         Set goodsSet = goodsItems.entrySet();
/* 391 */         Iterator iterator = goodsSet.iterator();
/* 392 */         while (iterator.hasNext()) {
/* 393 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 394 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 395 */           if ((goodsInstance.getDiscount_id() != null) && (!"".equals(goodsInstance.getDiscount_id()))) {
/* 396 */             discountids = disinfo.getVoucherInfoByPk(goodsInstance.getDiscount_id());
/* 397 */             if ((discountids != null) && (discountids.size() > 0)) {
/* 398 */               temp = (Hashtable)discountids.get(0);
/* 399 */               num = Integer.parseInt(temp.get("voucher_num").toString());
/* 400 */               if (num > 0) {
/* 401 */                 if (disMap.containsKey(temp.get("voucher_type"))) {
/* 402 */                   tempid = disMap.get(temp.get("voucher_type")).toString();
/* 403 */                   tempnum = Integer.parseInt(tempid.substring(tempid.indexOf("|") + 1, tempid.length()));
/*     */ 
/* 405 */                   disMap.put(temp.get("voucher_type"), temp.get("voucher_name") + "|" + tempnum + num);
/*     */                 }
/*     */                 else {
/* 408 */                   disMap.put(temp.get("voucher_type"), temp.get("voucher_name") + "|" + num);
/*     */                 }
/*     */ 
/*     */               }
/*     */ 
/*     */             }
/*     */ 
/*     */           }
/*     */ 
/*     */         }
/*     */ 
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 424 */     if (disMap.size() > 0) {
/* 425 */       StringBuffer buf = new StringBuffer();
/* 426 */       for (Iterator i$ = disMap.keySet().iterator(); i$.hasNext(); ) { Object key = i$.next();
/* 427 */         buf.append("<option value='" + key + "'>" + disMap.get(key).toString() + "</option>");
/*     */       }
/*     */ 
/* 430 */       return buf.toString();
/*     */     }
/* 432 */     return "";
/*     */   }
/*     */ 
/*     */   public int getAllItemsCount()
/*     */   {
/* 439 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 440 */       return 0;
/*     */     }
/* 442 */     int totalCount = 0;
/* 443 */     Set cartSet = this.cartMap.entrySet();
/* 444 */     Iterator cartIterator = cartSet.iterator();
/* 445 */     while (cartIterator.hasNext()) {
/* 446 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 447 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 448 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 449 */         Set goodsSet = goodsItems.entrySet();
/* 450 */         Iterator iterator = goodsSet.iterator();
/* 451 */         while (iterator.hasNext()) {
/* 452 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 453 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 454 */           totalCount += goodsInstance.getBuy_num();
/*     */         }
/*     */       }
/*     */     }
/* 458 */     return totalCount;
/*     */   }
/*     */ 
/*     */   public String getAllItemsOrderGoods()
/*     */   {
/* 463 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 464 */       return "";
/*     */     }
/* 466 */     int totalCount = 0;
/* 467 */     float totalPrice = 0.0F;
/* 468 */     Set cartSet = this.cartMap.entrySet();
/* 469 */     Iterator cartIterator = cartSet.iterator();
/* 470 */     while (cartIterator.hasNext()) {
/* 471 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 472 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 473 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 474 */         Set goodsSet = goodsItems.entrySet();
/* 475 */         Iterator iterator = goodsSet.iterator();
/* 476 */         while (iterator.hasNext()) {
/* 477 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 478 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 479 */           if ((goodsInstance.getDiscount_id() == null) || ("".equals(goodsInstance.getDiscount_id()))) {
/* 480 */             totalCount += goodsInstance.getBuy_num();
/* 481 */             totalPrice += goodsInstance.getTotalShopPrice();
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 486 */     return totalCount + "," + totalPrice;
/*     */   }
/*     */ 
/*     */   public double getAllItemsWeight()
/*     */   {
/* 491 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 492 */       return 0.0D;
/*     */     }
/* 494 */     double totalWeight = 0.0D;
/* 495 */     Set cartSet = this.cartMap.entrySet();
/* 496 */     Iterator cartIterator = cartSet.iterator();
/* 497 */     while (cartIterator.hasNext()) {
/* 498 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 499 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 500 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 501 */         Set goodsSet = goodsItems.entrySet();
/* 502 */         Iterator iterator = goodsSet.iterator();
/* 503 */         while (iterator.hasNext()) {
/* 504 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 505 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 506 */           totalWeight += goodsInstance.getWeight();
/*     */         }
/*     */       }
/*     */     }
/* 510 */     return totalWeight;
/*     */   }
/*     */ 
/*     */   public int getAllItemsCounts(String cust_id)
/*     */   {
/* 517 */     if ((!cust_id.equals("")) && (cust_id == null)) {
/* 518 */       return 0;
/*     */     }
/* 520 */     int totalCount = 0;
/*     */ 
/* 522 */     if (this.cartMap.containsKey(cust_id)) {
/* 523 */       Hashtable goodsItems = (Hashtable)this.cartMap.get(cust_id);
/* 524 */       Set goodsSet = goodsItems.entrySet();
/* 525 */       Iterator iterator = goodsSet.iterator();
/* 526 */       while (iterator.hasNext()) {
/* 527 */         Map.Entry entry = (Map.Entry)iterator.next();
/* 528 */         Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 529 */         totalCount += goodsInstance.getBuy_num();
/*     */       }
/*     */     }
/*     */ 
/* 533 */     return totalCount;
/*     */   }
/*     */ 
/*     */   public int getAllItemsIntegralNum()
/*     */   {
/* 538 */     if ((this.cartMap.size() <= 0) && (this.cartMap == null)) {
/* 539 */       return 0;
/*     */     }
/* 541 */     int totalIntegralNum = 0;
/*     */ 
/* 543 */     Set cartSet = this.cartMap.entrySet();
/*     */ 
/* 545 */     Iterator cartIterator = cartSet.iterator();
/*     */ 
/* 547 */     while (cartIterator.hasNext()) {
/* 548 */       Map.Entry cartEntry = (Map.Entry)cartIterator.next();
/* 549 */       if (this.cartMap.containsKey(cartEntry.getKey())) {
/* 550 */         Hashtable goodsItems = (Hashtable)this.cartMap.get(cartEntry.getKey());
/* 551 */         Set goodsSet = goodsItems.entrySet();
/* 552 */         Iterator iterator = goodsSet.iterator();
/* 553 */         while (iterator.hasNext()) {
/* 554 */           Map.Entry entry = (Map.Entry)iterator.next();
/* 555 */           Goods goodsInstance = (Goods)goodsItems.get(entry.getKey());
/* 556 */           totalIntegralNum += goodsInstance.getTotalIntegralNum();
/*     */         }
/*     */       }
/*     */     }
/* 560 */     return totalIntegralNum;
/*     */   }
/*     */ 
/*     */   public Goods updateDiscount(Goods goodsInstance) {
/* 564 */     Ti_discountpolicyInfo info = new Ti_discountpolicyInfo();
/* 565 */     List dislist = info.getListByPk(goodsInstance.getDiscount_id());
/* 566 */     if ((dislist != null) && (dislist.size() > 0)) {
/* 567 */       int num = goodsInstance.getBuy_num();
/* 568 */       float price = goodsInstance.getVip_price();
/* 569 */       if (price < 1.0F)
/* 570 */         price = goodsInstance.getShop_price();
/* 571 */       Map disMap = (Hashtable)dislist.get(0);
/* 572 */       float spending = 0.0F;
/* 573 */       float number = 0.0F;
/* 574 */       float discount = 0.0F;
/* 575 */       float ship_offer = 0.0F;
/* 576 */       float offer_price = 0.0F;
/* 577 */       String gift_id = "";
/* 578 */       int sendnumber = 0;
/* 579 */       int offer_type = Integer.parseInt(disMap.get("offer_type").toString());
/* 580 */       switch (offer_type) {
/*     */       case 1:
/* 582 */         gift_id = disMap.get("gift_ids").toString();
/* 583 */         sendnumber = 1;
/* 584 */         offer_price = price;
/* 585 */         break;
/*     */       case 2:
/* 588 */         spending = Float.parseFloat(disMap.get("spending").toString());
/* 589 */         if (price * num >= spending) {
/* 590 */           discount = Float.parseFloat(disMap.get("discount").toString());
/*     */ 
/* 592 */           offer_price = price * num * discount / 100.0F / num;
/*     */         } else {
/* 594 */           offer_price = price;
/*     */         }
/* 596 */         break;
/*     */       case 3:
/* 598 */         number = Float.parseFloat(disMap.get("number").toString());
/* 599 */         if (num >= number) {
/* 600 */           discount = Float.parseFloat(disMap.get("discount").toString());
/*     */ 
/* 602 */           offer_price = price * num * discount / 100.0F / num;
/*     */         } else {
/* 604 */           offer_price = price;
/*     */         }
/* 606 */         break;
/*     */       case 4:
/* 608 */         ship_offer = Float.parseFloat(disMap.get("ship_offer").toString());
/* 609 */         spending = Float.parseFloat(disMap.get("spending").toString());
/* 610 */         if (price * num >= spending)
/* 611 */           offer_price = (price * num - ship_offer) / num;
/*     */         else {
/* 613 */           offer_price = price;
/*     */         }
/* 615 */         break;
/*     */       case 5:
/* 617 */         spending = Float.parseFloat(disMap.get("spending").toString());
/* 618 */         if (price * num >= spending) {
/* 619 */           gift_id = disMap.get("gift_ids").toString();
/* 620 */           sendnumber = 1;
/*     */         } else {
/* 622 */           offer_price = price;
/*     */         }
/* 624 */         break;
/*     */       case 6:
/* 626 */         number = Float.parseFloat(disMap.get("number").toString());
/* 627 */         if (num >= number) {
/* 628 */           sendnumber = Integer.parseInt(disMap.get("send_a_few").toString());
/* 629 */           gift_id = disMap.get("gift_ids").toString();
/*     */         } else {
/* 631 */           offer_price = price;
/*     */         }
/*     */       }
/*     */ 
/* 635 */       goodsInstance.setGift_id(gift_id);
/* 636 */       goodsInstance.setSendnumber(sendnumber);
/* 637 */       goodsInstance.setOffer_price(offer_price);
/*     */     }
/* 639 */     return goodsInstance;
/*     */   }
/*     */ 
/*     */   public String getGift_ids() {
/* 643 */     return this.gift_ids;
/*     */   }
/*     */ 
/*     */   public void setGift_ids(String gift_ids) {
/* 647 */     this.gift_ids = gift_ids;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.shopcart.CartServices
 * JD-Core Version:    0.6.0
 */